﻿@using ChGK.Data;

@if (ViewBag.Role == "User") 
    {Layout = "~/Views/Shared/_LayoutUser.cshtml";}
 else if (ViewBag.Role == "Superuser")
    {Layout = "~/Views/Shared/_LayoutSuperuser.cshtml";}
 else
    {Layout = "~/Views/Shared/_Layout.cshtml";}


@{
    ViewBag.Title = "Турнирная таблица";
}

<style type = "text/css">
table#hidden
{
    border-width: 0;
}

table#hidden td
{
    text-align: center;
    border-width: 0;
}

table
{
    border: medium solid black;
}

table td
{
    
    border-top-width: 0;
    border-left: thin solid black;
    border-right: thin solid black;
    border-bottom: thin solid black;
    padding: 2.5px 5px 2.5px 5px;
}

.HeaderCell
{
    border: thin solid black;
    border-bottom: 2px solid black;
    padding: 2.5px 5px 2.5px 5px;
}

.SpecialHeaderCell
{
    border: thin solid black;
    border-bottom: 2px solid black;
    border-left-width: 2px;
    text-align: center;
    padding: 2.5px 5px 2.5px 5px;
}

.SpecialCell
{
    text-align: center;
    border-left-width: 2px;
    border-top-width: 0;
}

.AtCenter
{
    margin-left: auto;
    margin-right: auto;
}

.EvenCell
{
    background-color: Gray;
}
</style>

<h2 align = "center">@ViewData["Competition"]</h2>

<table class = "AtCenter">
    <tr>
        <td class = "HeaderCell">Команда</td>
        <td class = "HeaderCell">Город</td>
        @for (int i = 1; i <= (int)ViewData["NumberOfUsedTours"]; i++)
        {
            if (i == 1)
            {
                <td class = "SpecialHeaderCell">Тур @i</td>
            }
            else
            {
                <td class = "HeaderCell">Тур @i</td>
            }
        }
        <td class = "SpecialHeaderCell">Сумма</td>
    </tr>
    @{int j = 0;}
    @foreach (Team t in (IEnumerable<Team>)ViewData["Teams"])
    {
        string color;
        if (j % 2 != 0)
        {
            color = "#e0e0e0";
        }
        else
        {
            color = "white";
        }
        <tr bgcolor = @color>
            <td>@t.Caption</td>
            <td>@t.City</td>
            
            @for (int i = 1; i <= (int)ViewData["NumberOfUsedTours"] + 1; i++)
            {
                if (i == 1 || i == (int)ViewData["NumberOfUsedTours"] + 1)
                {
                    <td class = "SpecialCell">@Model[j][i]</td>
                }
                else
                {
                    <td align = "center">@Model[j][i]</td>
                }
            }

            @{j++;}
        </tr>
    }
</table>
<table class = "AtCenter" width = "80%" id = "hidden">
    <tr>
    @for (j = 1; j <= (int)ViewData["NumberOfTours"]; j++)
    {
        <td align = "center">@Html.ActionLink("Тур " + @j.ToString(), "TourTable", new { CompetitionID = @ViewData["CompetitionID"], TourNumber = j })</td>
    }
        <td align = "center">Итог</td>
    
    </tr>
</table>